Handle non-native windows in the gdk test utils
authorAlexander Larsson <alexl@redhat.com>
Wed, 8 Jul 2009 16:40:05 +0000 (18:40 +0200)
committerAlexander Larsson <alexl@redhat.com>
Wed, 8 Jul 2009 16:47:43 +0000 (18:47 +0200)
We need to add the non-native offset to the root coords when
sending events.

gdk/x11/gdktestutils-x11.c

index 480da4d909a2de3bc9af3d724a47edb3b0a7481a..13677b6a4266b83c1413e04c8e49931171a430be 100644 (file)
@@ -86,6 +86,7 @@ gdk_test_simulate_key (GdkWindow      *window,
 {
   GdkScreen *screen;
   GdkKeymapKey *keys = NULL;
+  GdkWindowObject *priv;
   gboolean success;
   gint n_keys = 0;
   XKeyEvent xev = {
@@ -104,6 +105,12 @@ gdk_test_simulate_key (GdkWindow      *window,
       x /= 2;
       y /= 2;
     }
+
+  priv = (GdkWindowObject *)window;
+  /* Convert to impl coordinates */
+  x = x + priv->abs_x;
+  y = y + priv->abs_y;
+
   xev.type = key_pressrelease == GDK_KEY_PRESS ? KeyPress : KeyRelease;
   xev.display = GDK_DRAWABLE_XDISPLAY (window);
   xev.window = GDK_WINDOW_XID (window);
@@ -190,6 +197,7 @@ gdk_test_simulate_button (GdkWindow      *window,
     1,  /* send_event */
   };
   gboolean success;
+  GdkWindowObject *priv;
 
   g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE);
   g_return_val_if_fail (window != NULL, FALSE);
@@ -203,6 +211,12 @@ gdk_test_simulate_button (GdkWindow      *window,
       x /= 2;
       y /= 2;
     }
+
+  priv = (GdkWindowObject *)window;
+  /* Convert to impl coordinates */
+  x = x + priv->abs_x;
+  y = y + priv->abs_y;
+
   xev.type = button_pressrelease == GDK_BUTTON_PRESS ? ButtonPress : ButtonRelease;
   xev.display = GDK_DRAWABLE_XDISPLAY (window);
   xev.window = GDK_WINDOW_XID (window);